/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ca.jerg.mcneely;

/**
 *
 * @author dave
 */
public class ErgMcneely 
{	
	private ErgMcneelyPanel emp;
	
	public static void main( String[] args )
	{
        ErgMcneely en = new ErgMcneely();		
	}
	
	public ErgMcneely()
	{
		emp = new ErgMcneelyPanel(this);
		emp.setVisible(true);
		emp.appendToOutput(DESCRIPTION);		
	}
	
	public void analyze( double peak, double vo2, double thres, double aero )
	{		
		double ratioV02Peak = 0;
		double ratioThresVO2 = 0;
		double ratioAeroVO2 = 0;
		
		if ( peak > 0.0 )
			ratioV02Peak = vo2 / peak * 100.0;
		
		if ( vo2 > 0.0 )
		{
			ratioThresVO2 = thres / vo2 * 100.0;
			ratioAeroVO2 = aero / vo2 * 100.0;
		}
		
		emp.updateRatios(ratioV02Peak,ratioThresVO2,ratioAeroVO2);
		emp.clearOutput();
		emp.appendToOutput(DESCRIPTION);
		emp.appendToOutput("\nNEEDS ADDRESSING\n");
		
		/*
		 * ratios that are too small, address
		 * the numerator
		 */		
		if ( ratioV02Peak < MIN_VO2_PEAK )
			emp.appendToOutput(VO2_POWER_DESC);
		
		if ( ratioThresVO2 < MIN_THRES_VO2 )
			emp.appendToOutput(THRES_POWER_DESC);

		if ( ratioAeroVO2 < MIN_AERO_VO2 )
			emp.appendToOutput(AERO_POWER_DESC);
		
		
		/*
		 * ratios that are too large, address
		 * the denomenator
		 */
		// first address limits on peak power
		if ( ratioV02Peak > MAX_VO2_PEAK )
			emp.appendToOutput(PEAK_POWER_DESC);
		
		// next address VO2 power
		if ( (ratioThresVO2 > MAX_THRES_VO2) || (ratioAeroVO2 > MAX_AERO_VO2) )
			emp.appendToOutput(VO2_POWER_DESC);
	}
	
	public static final double MIN_VO2_PEAK = 40.0;
	public static final double MAX_VO2_PEAK = 45.0;
	public static final double MIN_THRES_VO2 = 80.0;
	public static final double MAX_THRES_VO2 = 85.0;
	public static final double MIN_AERO_VO2 = 70.0;
	public static final double MAX_AERO_VO2 = 75.0;
	public static final String DESCRIPTION = 
			"IDEAL RATIOS:\n" +
			" VO2 Max to Peak Power = 40 - 45%\n" +
			" Threshold to VO2 Max Power = 80 - 85%\n" +
			" Aerobic to VO2 Max Power = 70 - 75%\n";
	
	public static final String PEAK_POWER_DESC = 
			" Peak power: include several jumps or town sign sprints\n" +
			"  in any workout\n";
	
	public static final String VO2_POWER_DESC =
			" VO2 power: series of 2-3 minute intervals\n";
	
	public static final String THRES_POWER_DESC =
			" Threshold power: series of 10-15 minute intervals\n";
	
	public static final String AERO_POWER_DESC =
			" Aerobic power: increase saddle time at a steady pace\n";
}
